//
//  BaseViewController.m
//  chargeAPP
//
//  Created by admin on 2017/3/28.
//  Copyright © 2017年 CarCharge. All rights reserved.
//

#import "BaseViewController.h"
#import "BaseNavigationViewController.h"
@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;//禁止自动调整,会导致页面下移
    self.view.backgroundColor = [UIColor whiteColor];
    

}
-(void)setupNavigationTitleWithTitle:(NSString *)title {
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0, 200, 44)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = title;
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:LagerFontSize];
    self.navigationItem.titleView = titleLabel;
  
}

- (void)setLeftBarButtonItemWithNormalImageName:(NSString *)Normalname andSelectImageName:(NSString *)selectName
{
    self.navigationItem.leftBarButtonItems = nil;
    [self.navigationController.navigationBar setNeedsLayout];
    //设置导航栏左右按钮
    UIView *leftContentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 54, 44)];
    UIButton *letfButton = [[UIButton alloc] initWithFrame:leftContentView.bounds];
    [letfButton setImage:[UIImage imageNamed:Normalname] forState:UIControlStateNormal];
    [letfButton setImage:[UIImage imageNamed:selectName] forState:UIControlStateHighlighted];
    letfButton.imageEdgeInsets = UIEdgeInsetsMake(11, 10, 11, 22);
    [letfButton addTarget:self action:@selector(leftItemBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [leftContentView addSubview:letfButton];
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftContentView];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
}

- (void)setRightBarButtonItemWithNormalImageName:(NSString *)Normalname andSelectImageName:(NSString *)selectName
{
    self.navigationItem.rightBarButtonItem = nil;
    [self.navigationController.navigationBar setNeedsLayout];
    UIView *rightContentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 54, 44)];
    UIButton *rightButton = [[UIButton alloc] initWithFrame:rightContentView.bounds];
    [rightButton setImage:[UIImage imageNamed:Normalname] forState:UIControlStateNormal];
    [rightButton setImage:[UIImage imageNamed:Normalname] forState:UIControlStateHighlighted];
    rightButton.imageEdgeInsets = UIEdgeInsetsMake(11, 22+10, 11, 0);
    [rightButton addTarget:self action:@selector(rightItemBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [rightContentView addSubview:rightButton];
    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightContentView];
    self.navigationItem.rightBarButtonItem = rightBarButtonItem;

}

//左按钮点击事件
- (void)leftItemBtnClick:(UIButton *)sender
{

}
//右按钮点击事件
- (void)rightItemBtnClick:(UIButton *)sender
{
 
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}


- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
}

- (void)dealloc
{
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
}

@end
